package com.example.dormitory.service;


import com.example.dormitory.entity.*;
import com.example.dormitory.mapper.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
public class TdAttendWideService {

    @Autowired
    private TdAttendWideMapper tdAttendWideMapper;

    public int create(TdAttendWide tdAttendWide) {
        return tdAttendWideMapper.create(tdAttendWide);
    }

    public int delete(String ids) {
        String[] arr = ids.split(",");
        int row = 0;
        for (String s : arr) {
            if(!StringUtils.isEmpty(s)){
                tdAttendWideMapper.delete(Integer.parseInt(s));
            row++;
            }
        }
        return row;
    }

    public int delete(Integer id) {
        return tdAttendWideMapper.delete(id);
    }

    public int update(TdAttendWide tdAttendWide) {
        return tdAttendWideMapper.update(tdAttendWide);
    }

    public int updateSelective(TdAttendWide tdAttendWide) {
        return tdAttendWideMapper.updateSelective(tdAttendWide);
    }

    public PageInfo<TdAttendWide> query(TdAttendWide tdAttendWide) {
        if(tdAttendWide != null && tdAttendWide.getPage() != null){
            PageHelper.startPage(tdAttendWide.getPage(),tdAttendWide.getLimit());
        }
        return new PageInfo<TdAttendWide>(tdAttendWideMapper.query(tdAttendWide));
    }

    public TdAttendWide detail(Integer id) {
        return tdAttendWideMapper.detail(id);
    }

    public int count(TdAttendWide tdAttendWide) {
        return tdAttendWideMapper.count(tdAttendWide);
    }
}
